class Solution(object):
    def largestAltitude(self, gain):
        n = len(gain)
        for i in range(1, n):
            gain[i] += gain[i - 1]
        return max(max(gain), 0)